package com.oversea.models;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "major")
@org.hibernate.annotations.Entity(dynamicUpdate = true)
public class Major extends BaseModel {
	private static final long serialVersionUID = -5404056504167584942L;

	private Majortype majortype;
	private List<Course> courseList;  //开设的课程
	private String majorName;
	private String majorTerms;        //学制
	private String tuitionRange;      //学费范围
	private String majorFields;       //专业领域
	private String enrollmentTime;    //入学时间
	private String majorDescription;  //专业描述

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="major_type_id")
	public Majortype getMajortype() {
		return majortype;
	}

	public void setMajortype(Majortype majortype) {
		this.majortype = majortype;
	}
	
	@ManyToMany(cascade= {CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.LAZY)
	@JoinTable(name="course_major", joinColumns= {@JoinColumn(name="major_id")}, inverseJoinColumns= {@JoinColumn(name="course_id")})
	public List<Course> getCourseList() {
		return courseList;
	}

	public void setCourseList(List<Course> courseList) {
		this.courseList = courseList;
	}

	@Column
	public String getMajorName() {
		return majorName;
	}

	public void setMajorName(String majorName) {
		this.majorName = majorName;
	}

	@Column
	public String getMajorTerms() {
		return majorTerms;
	}

	public void setMajorTerms(String majorTerms) {
		this.majorTerms = majorTerms;
	}

	@Column
	public String getTuitionRange() {
		return tuitionRange;
	}

	public void setTuitionRange(String tuitionRange) {
		this.tuitionRange = tuitionRange;
	}

	@Column
	public String getMajorFields() {
		return majorFields;
	}

	public void setMajorFields(String majorFields) {
		this.majorFields = majorFields;
	}

	@Column
	public String getEnrollmentTime() {
		return enrollmentTime;
	}

	public void setEnrollmentTime(String enrollmentTime) {
		this.enrollmentTime = enrollmentTime;
	}

	@Column
	public String getMajorDescription() {
		return majorDescription;
	}

	public void setMajorDescription(String majorDescription) {
		this.majorDescription = majorDescription;
	}
	
}
